/**
 * 
 */
package acmCoder.baidu;

import java.util.Scanner;

/**
 * @author zhongfang
 *
 */
public class 区域划分 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String string = scanner.nextLine();
		scanner.close();
		int n = string.length();
		int e[] = new int[n + 1];
		int w[] = new int[n + 1];
		int eCount = 0;
		for (int i = 0; i < n; i++) {
			e[i] = eCount;
			if (string.charAt(i) == 'E') {
				eCount++;
			}
		}
		e[n] = eCount;
		int wCount = 0;
		for (int i = n - 1; i >= 0; i--) {
			if (string.charAt(i) == 'W') {
				wCount++;
			}
			w[i] = wCount;
		}

		int res = n;
		for (int i = 0; i <= n; i++) {
			res = Math.min(res, e[i] + w[i]);
		}
		System.out.println(res);
	}

}
